﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeta.Game;
using Zeta.Game.Internals.Actors;

namespace KadalaSpree.XCore
{
    public static partial class X
    {
        public static class Player
        {
            public static bool IsValid
            {
                get { return !(!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.Me.IsDead || ZetaDia.IsLoadingWorld || !ZetaDia.Service.IsValid || !ZetaDia.WorldInfo.IsValid); }
            }

            //internal static AnimationState CurrentAnimationState
            //{
            //    get
            //    {
            //        return ZetaDia.Me.isCommonData.AnimationState;
            //    }
            //}


            private static AnimationState _lastAnimationState = AnimationState.Invalid;
            public static AnimationState CurrentAnimationState
            {
                get
                {
                    try
                    {
                        using (ZetaDia.Memory.AcquireFrame())
                        {
                            _lastAnimationState = ZetaDia.Me.CommonData.AnimationState;
                        }
                    }
                    catch {}
                    return _lastAnimationState;
                }
            }

            public static bool IsCastingOrChanneling
            {
                get { return CurrentAnimationState == AnimationState.Casting || CurrentAnimationState == AnimationState.Channeling || CurrentAnimationState == AnimationState.Transform || CurrentAnimationState.ToString() == "13"; }
            }

            public static int BloodShards
            {
                get { return ZetaDia.CPlayer.BloodshardCount; }
            }

            public static bool IsTransitioning
            {
                get { return !ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.Me.IsDead || ZetaDia.IsLoadingWorld || !ZetaDia.Service.IsValid || !ZetaDia.WorldInfo.IsValid; }
            }

        }
    }
}
